﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using DTO;
namespace DAO
{
    public class TTXacNhanDAO
    {
        public static Boolean InsertDaXacNhan(TTXacNhanDTO tt)
        {
            bool ok = false;

            string sp = "usp_GPB_InsertDaXacNhan ";
            sp += String.Format(" '{0}','{1}','{2}',{3},N{4}"
                                + ",{5},{6},'{7}','{8}',N'{9}'"
                                + ",N'{10}','{11}',N'{12}','{13}','{14}'"
                                + ",'{15}','{16}','{17}','{18}',N'{19}'"
                                + ",'{20}','{21}',{22},{23},N{24}"
                                + ",'{25}',{26},{27},N'{28}','{29}'"
                                + ",'{30}',{31},{32},{33},'{34}'",
                tt.SoHS, tt.SoBN, tt.SoNV,tt.LoaiBN, tt.HoTen
                ,tt.NamSinh, tt.Gioi,tt.NgayLayMau,tt.NgayNhan, tt.ChuanDoan
                ,tt.PPMo, tt.IDDViChiDinh, tt.PTVien, tt.CDate, '0'
                ,'0',tt.DVuCode, tt.IDDviTHien,tt.IDBacSiCD,tt.Nghe
                ,tt.IDDViGuiMau,tt.SoXanh,tt.SoTien,tt.Iddonviksk,tt.Diachi
                ,tt.SoTieuBan,tt.Tuoi,tt.Lanmo,tt.ChatBP, tt.DienThoai
                ,tt.NgayGioCDMau,tt.SlgMau,tt.DDCoDinhMau,tt.Slg,tt.NgayDongTien);
            ok = Uit.it_SQL.ExecuteNonQuery(sp);
            
            return ok;
        }

        public static Boolean InsertChiDinh(TTXacNhanDTO tt)
        {
            bool ok = false;

            string sp = "usp_GPB_InsertChiDinh ";
            sp += String.Format(" '{0}','{1}','{2}','{3}',{4}"
                                + ",'{5}',N'{6}',N'{7}',N'{8}','{9}'"
                                + ",N'{10}',{11},{12},N'{13}'",
                tt.SoHS, tt.SoBN, tt.DVuCode, tt.SoNV, tt.LoaiBN
                , tt.NgayLayMau, tt.ChuanDoan, tt.PPMo, tt.Lanmo, tt.IDDViChiDinh           
                , tt.PTVien, tt.IDBacSiCD,tt.IDDViGuiMau,tt.ChatBP);
            ok = Uit.it_SQL.ExecuteNonQuery(sp);

            return ok;
        }

        public static Boolean UpdateChiDinh(TTXacNhanDTO tt)
        {
            bool ok = false;

            string sp = "usp_GPB_UpdatePhieuCD ";
            sp += String.Format(" '{0}','{1}','{2}',N'{3}',{4}"
                                +",{5},'{6}','{7}',{8},'{9}'",
                tt.SoHS,tt.SoBN,tt.DVuCode,tt.ChuanDoan, tt.PPMo
                , tt.Lanmo, tt.IDDViChiDinh, tt.PTVien, tt.IDBacSiCD,tt.IDDViGuiMau);
            ok = Uit.it_SQL.ExecuteNonQuery(sp);

            return ok;
        }

        public static Boolean DeleteDaXacNhan(string SoHS, string SoBN)
        {
            bool ok = false;

            string sp = "usp_GPB_DeleteDaXacNhanDV ";
            sp += String.Format(" '{0}','{1}'", SoHS, SoBN);
            ok = Uit.it_SQL.ExecuteNonQuery(sp);
            return ok;
        }

        public static DataTable GetMax(int LoaiSo, int Nam, int Thang)
        {
            DataTable dtKQ = new DataTable();
            string sp = "usp_GPB_GetSoMax ";
            sp += String.Format(" {0},{1},{2}", LoaiSo, Nam, Thang);
            dtKQ = Uit.it_SQL.getDataTable(sp);

            return dtKQ;
        }

        public static Boolean UpdateMax(int Loai , int Nam, int Thang, int Max)
        {
            bool ok = false;

            string sp = "usp_GPB_UpdateSoMax ";
            sp += String.Format(" {0},{1},{2},{3}", Loai, Nam, Thang, Max);
            ok = Uit.it_SQL.ExecuteNonQuery(sp);

            return ok;
        }
    }
}
